package com.tanhua.server.controller;

import com.tanhua.domain.vo.RecommendQueryVo;
import com.tanhua.domain.vo.TodayBestVo;
import com.tanhua.server.service.TodayBestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("tanhua")
public class TodayBestController {
    @Autowired
    private TodayBestService todayBestService;

    /**
     * 接口名称：今日佳人
     * 接口路径：GET/tanhua/todayBest
     * 需求描述：查询缘分值最高的用户。 首页 进入佳人
     */
    @GetMapping("todayBest")
    public ResponseEntity<Object> todayBest(){
        return todayBestService.queryTodayBest();
    }

    /**
     * 接口名称：推荐朋友
     * 接口路径：GET/tanhua/recommendation
     * 需求描述：首页 查询推荐用户分页列表
     */
    @GetMapping("recommendation")
    public ResponseEntity<Object> recommendation(RecommendQueryVo vo){
        return todayBestService.queryRecommendation(vo);
    }

    /**
     * 接口名称：佳人信息
     * 接口路径：GET/tanhua/:id/personalInfo
     */
    @GetMapping("{id}/personalInfo")
    public ResponseEntity<Object> queryPersonalInfo(
            @PathVariable("id") Long recommendUserId){
        return todayBestService.queryPersonalInfo(recommendUserId);
    }

    /**
     * 接口名称：查询陌生人问题
     * 接口路径：GET/tanhua/strangerQuestions
     */
    @GetMapping("strangerQuestions")
    public ResponseEntity<Object> strangerQuestions(Long userId){
        return todayBestService.strangerQuestions(userId);
    }

    /**
     * 接口名称：回复陌生人问题
     * 接口路径：POST/tanhua/strangerQuestions
     */
    @PostMapping("strangerQuestions")
    public ResponseEntity<Object> replyQuestion(
            @RequestBody Map<String,String> map){
        Long userId = Long.parseLong(map.get("userId"));
        String reply = map.get("reply");
        return todayBestService.replyQuestion(userId,reply);
    }


    /**
     * 接口名称：搜附近
     * 接口路径：GET/tanhua/search
     */
    @GetMapping("search")
    public ResponseEntity<Object> searchNear(String gender,Long distance){
        return todayBestService.searchNear(gender,distance);
    }

    /**
     * 接口名称：探花-喜欢
     * 接口路径：GET/tanhua/:id/love
     */
    @GetMapping("{uid}/love")
    public ResponseEntity<Object> likeRecommend( @PathVariable("uid") Long likeUserId){
        return todayBestService.likeRecommend(likeUserId);
    }

    /**
     * 接口名称：探花-喜欢
     * 接口路径：GET/tanhua/:id/unlove
     */
    @GetMapping("{uid}/unlove")
    public ResponseEntity<Object> unLikeRecommend( @PathVariable("uid") Long unLikeUserId){
        return todayBestService.unLikeRecommend(unLikeUserId);
    }

    /**
     * 接口名称：探花-左滑右滑
     * 状  态：已完成更新
     * 接口路径：GET/tanhua/cards
     * 说明：原型中计划普通用户限量100个，开通会员后可以增加限额。开通会员的功能暂时没有实现，先直接限额100
     */
    @GetMapping("cards")
    public ResponseEntity<Object> cards(){
        return todayBestService.displayCards();
    }
}
